#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=2e5+4;
int id[16],po[16],n,cnt,t[N];
vector<tuple<int,int,int> > g;
void add(int x,int y,int z){
    if(z<=n){
        // cout<<x<<" "<<y<<" "<<z<<"\n";
        g.push_back({x,y,z});
        if(!t[x]) cnt++,t[x]++;
        if(!t[y]) cnt++,t[y]++;
    }
}
signed main(){
    freopen("road.in","r",stdin);
    freopen("road.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    cin>>n;
    po[0]=1;
    for(int i=1;i<=14;i++)
        po[i]=po[i-1]*2;
    for(int i=2;i<=15;i++) id[i]=i;
    id[1]=1,id[16]=114;
    for(int i=2;i<=15;i++) add(id[i],id[i+1],po[15-i]),add(id[i],id[i+1],0);
    int res=0;
    for(int i=14;~i;i--){
        if((1<<i)&n){
            add(id[1],id[16-i],res);
            res|=(1<<i);
        }
    }
    add(id[1],id[16],res);
    cout<<cnt<<" "<<g.size()<<"\n";
    for(int i=0;i<g.size();i++){
        int x=get<0>(g[i]);
        int y=get<1>(g[i]);
        int z=get<2>(g[i]);
        cout<<x<<" "<<y<<" "<<z<<"\n";
    }
    return 0;
}